<?php
require_once(PATH_MEDIA."component".DIRECTORY_SEPARATOR."recaptcha".DIRECTORY_SEPARATOR."recaptchalib.php");

class Helper_Captcha
{
	function create(){
		$publickey = "6LfVW7wSAAAAABBXYk-tlDr4OEQlj0GP5o1GqHj_";
		echo recaptcha_get_html($publickey);
	}

	function validate()
	{
		$privatekey = "6LfVW7wSAAAAAJD9Lt_cHTwuC6CZquMFRHzwyE11";
		$resp = recaptcha_check_answer ($privatekey,
										$_SERVER["REMOTE_ADDR"],
										$_POST["recaptcha_challenge_field"],
										$_POST["recaptcha_response_field"]);

		if (!$resp->is_valid) {
			// What happens when the CAPTCHA was entered incorrectly
			return array(false, "The reCAPTCHA wasn't entered correctly. Go back and try it again.".
				"(reCAPTCHA said: " . $resp->error . ")");
		} else {
			return array(true);
		}
	}
}
?>